package com.luo.chengrui.module.sa.dal.mysql.commontree;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.luo.chengrui.module.sa.dal.dataobject.commontree.CommonTreeBizDO;
import org.apache.ibatis.annotations.Mapper;
import com.luo.chengrui.module.sa.controller.admin.commontree.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 业务树 业务端通用树结构，必须与SA_COMMON_TREE表数据合并使用 Mapper
 *
 * @author 诚睿
 */
@Mapper
public interface CommonTreeBizMapper extends BaseMapperX<CommonTreeBizDO> {

    default PageResult<CommonTreeBizDO> selectPage(CommonTreeBizPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CommonTreeBizDO>()
                .eqIfPresent(CommonTreeBizDO::getKindId, reqVO.getKindId())
                .likeIfPresent(CommonTreeBizDO::getCode, reqVO.getCode())
                .eqIfPresent(CommonTreeBizDO::getShortCode, reqVO.getShortCode())
                .eqIfPresent(CommonTreeBizDO::getNodeKindId, reqVO.getNodeKindId())
                .likeIfPresent(CommonTreeBizDO::getName, reqVO.getName())
                .eqIfPresent(CommonTreeBizDO::getExtendContent, reqVO.getExtendContent())
                .eqIfPresent(CommonTreeBizDO::getRemark, reqVO.getRemark())
                .eqIfPresent(CommonTreeBizDO::getParentId, reqVO.getParentId())
                .eqIfPresent(CommonTreeBizDO::getSequence, reqVO.getSequence())
                .eqIfPresent(CommonTreeBizDO::getVersion, reqVO.getVersion())
                .eqIfPresent(CommonTreeBizDO::getStatus, reqVO.getStatus())
                .likeIfPresent(CommonTreeBizDO::getFullId, reqVO.getFullId())
                .likeIfPresent(CommonTreeBizDO::getFullName, reqVO.getFullName())
                .orderByDesc(CommonTreeBizDO::getId));
    }

    public List<CommonTreeBizDO> selectList(@Param("params") CommonTreeBizExportReqVO reqVO);

    CommonTreeBizDO selectByParentId(@Param("params") CommonTreeBizDO commonTreeBiz);

    CommonTreeBizDO selectByParentIdAndName(@Param("params") CommonTreeBizDO commonTreeBiz);

    CommonTreeBizDO selectByCode(@Param("params") CommonTreeBizDO commonTreeBiz);
}
